@extends('admin.app')

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      代码信息表单
    </div>
    <div class="panel-body">
      <form class="form-horizontal form-validation" action="{{ admin_action('Gift\ActivityController@update', [$info]) }}" method="post">
        {{ csrf_field() }}
        {{ method_field('PUT') }}
        <input type="hidden" id="activity_id" value="{{$info->id}}"/>
        <div class="form-group">
          <label class="col-lg-2 control-label">名称*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="name" value="{{ $info->name }}" placeholder="请输入名称" data-rule-required="true" data-rule-maxlength="200"> 
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">活动分类</label>
          <div class="col-lg-10">
            <select name="cate_id" class="form-control select2">
              <option value="">请选择</option>
              @foreach($cates as $item)
              <option value="{{$item->code}}" {{$info->cate_id==$item->code?'selected':''}}>{{$item->name}}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">红包总额*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="total_money" value="{{ $info->total_money }}" placeholder="请输入红包总额" data-rule-number="true" data-rule-required="true"/> 
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">活动类型*</label>
          <div class="col-lg-10">
            <select name="type_id" class="form-control select2" data-rule-required="true">
              <option value="">请选择</option>
              @foreach($types as $item)
              <option value="{{$item->code}}" {{$info->type_id==$item->code?'selected':''}}>{{$item->name}}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">活动时间*</label>
          <div class="col-lg-5">
            <input type="text" class="form-control datetimepicker" name="begin_time" value="{{ $info->begin_time }}" placeholder="活动开始时间" data-rule-required="true"/> 
          </div>
          <div class="col-lg-5">
            <input type="text" class="form-control datetimepicker" name="end_time" value="{{ $info->end_time }}" placeholder="活动结束时间" data-rule-required="true"/> 
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">使用规则</label>
          <div class="col-lg-5">
            <select name="used_rule" class="form-control select2">
              <option value="">请选择</option>
              @foreach($rules as $item)
              <option value="{{$item->code}}" {{$item->code==$info->used_rule?'selected':''}}>{{$item->name}}</option>
              @endforeach
            </select>
          </div>
          <div class="col-lg-5">
            <input type="text" class="form-control" name="used_rule_money" value="{{ $info->used_rule_money }}" placeholder="请输入金额" data-rule-number="true"/> 
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group" url="{{admin_action('Gift\ActivityController@getRule')}}">
          <label class="col-lg-2 control-label">发放规则*</label>
          <div class="col-lg-5">
            <select name="grant_rule" id="grant_rule" class="form-control select2">
              <option value="">请选择</option>
              @foreach($grants as $item)
              <option value="{{$item->code}}" <?=$info->grant_rule==$item->code?'selected':''?>>{{$item->name}}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">红包有效期*</label>
          <div class="col-lg-1 checkbox">
            <label class="i-checks"><input type="radio" name="effect" value="1" data-target="[name='effect_time1'],[name='effect_time2']" {{ $info->effect_time1?'checked':'' }}><i></i></label>
          </div>
          <div class="col-lg-4">
            <input type="text" class="form-control datetimepicker" name="effect_time1" value="{{ $info->effect_time1 }}" {{ $info->effect_time1?'':'disabled' }}/> 
          </div>
          <div class="col-lg-4">
            <input type="text" class="form-control datetimepicker" name="effect_time2" value="{{ $info->effect_time2 }}" {{ $info->effect_time1?'':'disabled' }}/> 
          </div>
        </div>
        <div class="form-group">
          <div class="col-lg-1 col-lg-offset-2 checkbox">
            <label class="i-checks"><input type="radio" name="effect" value="2" data-target="[name='effect_day']" {{ $info->effect_day?'checked':'' }}><i></i></label>
          </div>
          <div class="col-lg-8">
            <input type="number" class="form-control" name="effect_day" value="{{ $info->effect_day }}" placeholder="请输入红包有效天数" data-rule-number="true" {{ $info->effect_day?'':'disabled' }}/> 
            <span class="help-block">有效天数是按红包领取当天进行计算</span>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <div class="col-lg-4 col-lg-offset-2">
            <a href="{{ admin_action('Gift\ActivityController@index') }}" class="btn btn-default">返&nbsp;回</a>
            <button type="submit" class="btn btn-primary">保&nbsp;存</button>
          </div>
        </div>
      </form>
    </div>
  </div>
@endsection
@section('scripts')
<script src="{{ asset('resources/admin/js/gift.js') }}"></script>
@endsection